package vivek.project.pocketmoney.common
{
	import flash.data.SQLConnection;
	import flash.data.SQLMode;
	import flash.filesystem.File;
	
	import mx.collections.ArrayCollection;
	import mx.collections.ArrayList;
	import mx.formatters.CurrencyFormatter;
	import mx.formatters.DateFormatter;
	import mx.formatters.NumberFormatter;

	public class CommonData
	{
		public static const STATUS_EVENT:String="StatusBarChanged";
		[Bindable]
		public static var applicationInfoBar:ArrayCollection=new ArrayCollection();
		public static const currentMonth:int=new Date().getMonth() + 1;
		public static const currentYear:int=new Date().getFullYear();
		private static var dateFormatter:DateFormatter=new DateFormatter();
		public static const monthLabel:Array=["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
		private static var numberFormatter:NumberFormatter=new NumberFormatter();
		private static var numberFormatter4:NumberFormatter=new NumberFormatter();
		public static const rowHeight:int=18;
		private static var timeFormatter:DateFormatter=new DateFormatter();
		public static const yearLabel:ArrayList=new ArrayList(["2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017"]);;
		private static var _sqlConnection:SQLConnection=new SQLConnection();
		private static var currencyFormatter2:CurrencyFormatter=new CurrencyFormatter();
		private static var currencyFormatter4:CurrencyFormatter=new CurrencyFormatter();
		private static var file:File=File.applicationStorageDirectory.resolvePath("pm.dat");

		public static function getConnection():SQLConnection
		{
			//if (_sqlConnection==null)
			{
				_sqlConnection=new SQLConnection();
				_sqlConnection.open(file, SQLMode.UPDATE);
			}
			/*if (_sqlConnection.connected==false)
			 _sqlConnection.open(file,SQLMode.UPDATE);*/
			return _sqlConnection;
		}

		public static function getCurrencyFormatter():CurrencyFormatter
		{
			currencyFormatter2.thousandsSeparatorFrom=",";
			currencyFormatter2.thousandsSeparatorFrom=",";
			return currencyFormatter2;
		}

		public static function getCurrencyFormatter4():CurrencyFormatter
		{
			currencyFormatter4.precision=4;
			return currencyFormatter4;
		}

		public static function getDateFormatter():DateFormatter
		{
			dateFormatter.formatString="DD-MM-YYYY";
			return dateFormatter;
		}

		public static function getNumberFormatter():NumberFormatter
		{
			numberFormatter.precision=2;
			return numberFormatter;
		}

		public static function getNumberFormatter4():NumberFormatter
		{
			numberFormatter.precision=4;
			return numberFormatter4;
		}

		public static function getDateFormatterSlash():DateFormatter
		{
			dateFormatter.formatString="DD/MM/YYYY";
			return dateFormatter;
		}

		public function CommonData()
		{
			init();
		}
		[Bindable]
		public var connected:Boolean;

		private function init():void
		{
			/*dateFormatter.formatString=ResourceManager.getInstance().getString('FormattingValues', 'DATE_FORMAT');
			   timeFormatter.formatString=ResourceManager.getInstance().getString('FormattingValues', 'TIME_FORMAT');
			   currencyFormatter.precision=ResourceManager.getInstance().getInt('FormattingValues', 'CURRENCY_PRECISION');
			   currencyFormatter.currencySymbol=ResourceManager.getInstance().getString('FormattingValues','CURRENCY_SYMBOL');
			   currencyFormatter.thousandsSeparatorTo=ResourceManager.getInstance().getString('FormattingValues','THOUSANDS_SEPARATOR');
			 currencyFormatter.decimalSeparatorTo=ResourceManager.getInstance().getString('FormattingValues','DECIMAL_SEPARATOR');*/
			numberFormatter.precision=2;
			numberFormatter4.precision=4;
			numberFormatter4.useThousandsSeparator=false;
			numberFormatter.useThousandsSeparator=false;
		}
	}
}